package com.szq.day39.dao;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


import com.szq.day39.entity.Users;

@Repository
public class UsersDAO {
	@Autowired
	private SessionFactory sf;

	public Users findByUserNameAndPassword(String userName,String password) throws Exception{
		return sf.getCurrentSession().createQuery("from Users u where u.userName=:userName and u.password=:password", Users.class)
				.setParameter("userName", userName)
				.setParameter("password", password)
				.uniqueResult();
	}
	

}
